package com.mt;

import com.alibaba.fastjson.JSONObject;
import com.mt.mall.entity.Order.Order;
import com.mt.mall.entity.User.ShippingAddress;

import java.awt.*;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @ClassName: GenerTest
 * @Description:
 * @Author zhanghong
 * @Date 2022/5/29
 */
public class GenerTest {
    public static void main(String[] args) throws IOException {
        File file = new File("C:\\Users\\26071\\Desktop\\test.txt");

        if(!file.exists()){
            file.createNewFile();
        }

        //使用true，即进行append file

        FileWriter fileWritter = new FileWriter("C:\\Users\\26071\\Desktop\\test.txt",true);
        BufferedWriter out = new BufferedWriter(fileWritter);
        //out.write("[\n");
        //long times=10000L;
        //for (long i = 0; i < 10000; i++) {
        //    Order order=new Order();
        //    order.setUserId(i);
        //    order.setSkillCommodityId(1L);
        //    order.setCommodityId(1L);
        //    order.setSpecification("12+256G,蓝色");
        //    order.setCount(1);
        //    order.setUserAddressId(1L);
        //
        //    //System.out.println(JSONObject.toJSONString(order));
        //    out.write(JSONObject.toJSONString(order)+(i!=times-1?",\n":"\n"));
        //}
        //out.write("]");
        out.write("userId,count,commodityId,specification,userAddressId,skillCommodityId\n");

        for (long i = 0; i < 10000; i++) {
            //Order order=new Order();
            //order.setUserId(i);
            //order.setSkillCommodityId(1L);
            //order.setCommodityId(1L);
            //order.setSpecification("12+256G,蓝色");
            //order.setCount(1);
            //order.setUserAddressId(1L);
            StringBuilder stringBuilder=new StringBuilder();
            stringBuilder.append(i);
            stringBuilder.append(",");
            stringBuilder.append(1);
            stringBuilder.append(",");
            stringBuilder.append(1);
            stringBuilder.append(",");
            stringBuilder.append("12+256G-蓝色") ;
            stringBuilder.append(",");
            stringBuilder.append(1);
            stringBuilder.append(",");
            stringBuilder.append(1) ;

            stringBuilder.append(",\n");
            //System.out.println(stringBuilder.toString());
            //System.out.println(JSONObject.toJSONString(order));
            out.write(stringBuilder.toString());
        }
        //fileWritter.close();
        out.close();
    }
}
